/**
 * 
 */
package com.security.frame.core.social.weibo.config;

import com.security.frame.core.properties.SecurityProperties;
import com.security.frame.core.properties.WeiboProperties;
import com.security.frame.core.social.weibo.connet.WeiboConnectionFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;


/**
 * 微博登陆配置
 *
 * @author wangjie
 * @version V1.0
 * @date 2019/11/12
 */
@Configuration
@ConditionalOnProperty(prefix = "frame.security.social.weibo", name = "app-id")
@Slf4j
public class WeiboAutoConfig extends SocialAutoConfigurerAdapter {

	@Autowired
	private SecurityProperties securityProperties;


	@Override
	protected ConnectionFactory<?> createConnectionFactory() {
		WeiboProperties weiboConfig = securityProperties.getSocial().getWeibo();
		return new WeiboConnectionFactory(weiboConfig.getProviderId(), weiboConfig.getAppId(), weiboConfig.getAppSecret());
	}

}
